package com.designpatterns.listener;


public class DataReader {
	private DataReaderListener dataReaderListener;
	
	public void read() {
		// Delegate "before reading data" process to data reader listener.
		if(dataReaderListener != null) {
			dataReaderListener.beforeReading();
		}
		
		System.out.println("DataReader is reading data...");
		
		// Delegate "after reading data" process to data reader listener.
		if(dataReaderListener != null) {
			dataReaderListener.afterReading();
		}
	}
	
	public void setDataReaderListener(DataReaderListener dataReaderListener) {
		this.dataReaderListener = dataReaderListener;
	}
}
